﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using System.Collections.Generic;
using COM.OA.Entity;

public partial class rc_rc_writecalendar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    //发送
    protected void Button1_Click(object sender, EventArgs e)
    {
        //日程日期
        DateTime orderdate = DateTime.Parse(this.Request.Form["control_date"]);

        //标题
        string notetitle = this.Request.Form["zhuti"];

        //内容
        string notecontent = this.ftboxcontent.Text;

        //发送人
        string username = this.Request.Form["txtusername"];

        //发送人id
        int userid = 0;

        string sql3 = "u_username='{0}'";
        sql3 = string.Format(sql3, username);
        IList<users> userlist = usersBLL.Select(sql3);
        if (userlist.Count == 1)
        {
            foreach (users u in userlist)
            {
                userid = u.u_id;
            }
        }

        //发送时间
        DateTime sendtime = DateTime.Parse(this.Request.Form["txtsendtime"]);

        //状态
        int state = 0;

        //是否批阅
        int isread = 0;

        //批阅人id
        int readerid = 0;

        //批阅内容
        string readcontent = "";

        //批阅时间
        DateTime readtime = DateTime.Parse("2000-1-1");

        timeorder torder = new timeorder();
        torder.to_orderdate = orderdate;//日程日期
        torder.to_title = notetitle;//标题
        torder.to_content = notecontent;//内容
        torder.to_u_id = userid;//发送人id
        torder.to_sendtime = sendtime;//发送时间
        torder.to_state = state; //状态
        torder.to_isread = isread;//是否批阅
        torder.to_readerid = readerid;//批阅人id
        torder.to_readcontent = readcontent;//批阅内容
        torder.to_readtime = readtime; //批阅时间

        int flag = timeorderBLL.Insert(torder);
        if (flag == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('日程发送失败！！');</script>");
        }
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('日程发送成功！！');</script>");
        this.Response.Redirect("rc_employeenote.aspx");
    }
}
